from rest_framework.response import Response
from rest_framework.views import APIView
from neomodel import db
from network.utils import get_network


class ContactsView(APIView):

    def get(self, request):
        # cypher = """MATCH p=()-[r:CONTACT]->() RETURN p LIMIT 50"""
        # yolo
        # rows = db.cypher_query(cypher)
        data = get_network(mobile='13997670036')

        return Response(
            # 'status': 200,
            data
        )
        pass


class ContactsDetialView(APIView):
    def get(self, request, mobile):
        # cypher = """MATCH p=()-[r:CONTACT]->() RETURN p LIMIT 50"""
        #
        # rows = db.cypher_query(cypher)
        start_datetime = request.query_params.get('start_datetime')
        end_datetime = request.query_params.get('end_datetime')

        data = get_network(mobile=mobile, start_time=start_datetime, end_time=end_datetime)

        return Response(
            # 'status': 200,
            data
        )
        pass

    pass
